<script setup>
	import { onLaunch, onShow, onHide } from "@dcloudio/uni-app"
	import { useUserStore } from "@/stores/user.js"

	onLaunch(async () => {
		console.log('App Launch')
		const userStore = useUserStore()
		// 判断用户是否登录
		const token = userStore.userInfo.token
		if (!token) {
			try {
				const { code } = await uni.login()
				await userStore.login(code)
			} catch (e) {
				uni.showToast({ icon: "error", title: "自动登录失败" })
			}
		}
	})
	onShow(() => {
		console.log('App Show')
	})
	onHide(() => {
		console.log('App Hide')
	})
</script>

<style lang="scss">
	/*每个页面公共css */
	@import url("common/css/common.scss")
</style>